//
//  ViewController.swift
//  SwiftNetwork
//
//  Created by GorXion on 2018/4/17.
//  Copyright © 2018年 gaoX. All rights reserved.
//

import UIKit
import RxSwift


class ViewController: UIViewController {
    
    private let disposeBag = DisposeBag()

    override func viewDidLoad() {
        super.viewDidLoad()
        
        TestTarget.test(count: 10).cachedObject([TestModel].self, onCache: { (response) in
            debugPrint("onCache")
            debugPrint(response)
        }).request([TestModel].self, atKeyPath: "result").subscribe(onSuccess: { (response) in
            debugPrint("onSuccess")
            debugPrint(response)
        }, onError: nil).disposed(by: disposeBag)
//
//        TestTarget.test(count: 10).request([TestModel].self, atKeyPath: "result").subscribe(onSuccess: { (response) in
//            debugPrint("onSuccess")
//            debugPrint(response)
//        }, onError: nil).disposed(by: disposeBag)
        
        TestTarget.test(count: 10).requestWithCache([TestModel].self, atKeyPath: "result").subscribe(onNext: { (response) in
            debugPrint("onNext")
            debugPrint(response)
        }).disposed(by: disposeBag)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

